<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>入库申请查询</title>

    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/admin.css">
    <link rel="stylesheet" href="../css/bootstrap.css">

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/bootstrap-table1.15.3.js"></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>

    <style>
        input{
            border-top: none;
            border-left: none;
            border-right: none;
            border-bottom: black solid 1px;
        }

        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
    </style>

</head>

<script>
    function initPutRegisterSelect(){
        $('#putRegisterSelectTableInfo').bootstrapTable(
            {
                //请求方式
                method:'post',
                contentType:'application/json',
                url:'/SGather/queryRegisterSelectAll.action',
                //设置交替样式
                striped:true,
                //初始显示页号
                pageNumber:1,
                //是否显示分页
                pagination:true,
                //是否设置服务端分页还是客户端分页
                sidePagination:'server',
                //页面大小
                pageSize:3,
                //分页列表
                pageList:[1,3,5,6,10],
                //上传到到服务端的参数
                queryParams:function (pares) {
                    return{
                        //计算页号（当前页）
                        pageNum:(pares.offset/pares.limit)+1,
                        //计算页大小
                        pageSize:pares.limit,
                    }
                },
                //第一列名
                columns:[
                    {title:"申请单编号",field:"gatherId",align:"center",formatter:function (value,row,index) {
                            return "<a href='#' onclick='queryAll("+JSON.stringify(row)+")' data-toggle='modal' data-target='#putRegisterSelectModal'>"+value+"</a>"
                        }},
                    {title:"入库理由",field:"reason",align:"center",formatter:function (value,row,index) {
                            if(value=="R001-1"){
                                return "生产入库";
                            }else if(value=="R001-2"){
                                return "库存初始";
                            }else if(value=="R001-3"){
                                return "赠送";
                            }else if(value=="R001-4"){
                                return "内部归还";
                            }else if(value=="R001-5"){
                                return "其他归还";
                            }
                        }},
                    {title:"登记时间",field:"registerTime",align:"center"},
                    {title:"总件数",field:"amountSum",align:"center"},
                    {title:"审核状态",field:"checkTag",align:"center",formatter:function (value,row,index) {
                            if(value=="S001-0"){
                                return "<span style='color: orange'>等待审核</span>"
                            }else if(value=="S001-1"){
                                return "<span style='color: greenyellow'>审核通过</span>"
                            }else if(value=="S001-2"){
                                return "<span style='color: red'>未通过</span>"
                            }
                        } }
                ]
            })
    }

    $(function () {
        initPutRegisterSelect();
    })

    function queryAll(rows) {

        $('#gatherId').text(rows.gatherId);
        $('#storer').text(rows.storer);

        if(rows.reason == 'R001-1'){
            $('#reason').text('生产入库');
        }else if(rows.reason == 'R001-2'){
            $('#reason').text('库存初始');
        }else if(rows.reason == 'R001-3'){
            $('#reason').text('赠送');
        }else if(rows.reason == 'R001-4'){
            $('#reason').text('内部借领');
        }else if(rows.reason == 'R001-5'){
            $('#reason').text('其他借领');
        }

        $('#amountSum').text(rows.amountSum);
        $('#costPriceSum').text(rows.costPriceSum);
        $('#register').text(rows.register);
        $('#checker').text(rows.register);
        $('#registerTime').text(rows.registerTime);
        $('#remark').text(rows.remark);
        //复核时间
        $('#checkTime').text(rows.checkTime);

        $('#tbodyId').empty();
        $.ajax({
            type:'post',
            url:'/sGatherDetails/querySGatherDetailsAll.action',
            data:'parentId='+rows.id,
            success:function (result) {
                let tbodyId = $('#tbodyId');
                $.each(result,function (i,res) {
                    let trObj = $('<tr>');
                    tbodyId.append(trObj);
                    trObj.append($('<td>').text(i+1));
                    trObj.append($('<td>').text(res.productName));
                    trObj.append($('<td>').text(res.productId));
                    //描述
                    trObj.append($('<td>').text(res.productDescribe));
                    //数量
                    trObj.append($('<td>').text(res.amount));
                    trObj.append($('<td>').text(res.amountUnit));
                    trObj.append($('<td>').text(res.costPrice));
                    //小计（元）
                    trObj.append($('<td>').text(res.subtotal));
                })
            }
        });
    }

</script>


<body bgcolor="#f5f5f5">

<div class="container-fluid">
    <div style="width: 100%;margin: 0px;padding: 0px;">
        <table id="putRegisterSelectTableInfo" class="table table-bordered table-hover table-striped table-condensed">

        </table>
    </div>
</div>

<!--模态框-->
<!--modal fade-->
<div class="modal  fade" id="putRegisterSelectModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form id="updateSGatherFormId">
        <div class="modal-dialog" style="width: 90%">
            <div class="modal-content" style="border: 1px solid black;">
                <div class="modal-header">
                    <div class="container">
                        <div class="row">
                            <div class="col-7" style="text-align: right">
                                <h5 class="modal-title" id="info" >
                                    入库申请单信息
                                </h5>
                            </div>
                            <div class="col-4" style="position: absolute;right: 30px">
<!--                                <input type="radio" class="radio" value="S001-2" name="checkTag">未通过-->
<!--                                <input type="radio" class="radio" value="S001-1" name="checkTag">通过-->
<!--                                <input type="button" class="btn btn-success btn-sm" id="submitBtn" value="确认"/>-->
<!--                                <button class="btn btn-sm btn-warning" onclick="window.location='putRegisterCheck.html'">返回</button>-->
                            </div>
                        </div>
                    </div>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right: 0px">

                    </button>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row" style="margin-top: 10px">
                            <div class="col-12">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div class="col-2">
                                            申请单编号:
                                        </div>
                                        <div class="col-3">
                                            <span id="gatherId"></span>
                                        </div>
                                    </div>
                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-2">
                                            入库人：
                                        </div>
                                        <div class="col-3" style="padding-left: 0px;margin-left: 0px;">
                                            <span id="storer"></span>
                                        </div>
                                        <div class="col-3" style="padding-left: 80px">
                                            入库理由：
                                        </div>
                                        <div class="col-4" style="padding-left: 0px;margin-left: 0px;">
                                            <!--<select class="form-control" name="reason" id="reason">
                                                <option value="R001-1">生产入库</option>
                                                <option value="R001-2">库存初始</option>
                                                <option value="R001-3">赠送</option>
                                                <option value="R001-4">内部借领</option>
                                                <option value="R001-5">其他借领</option>
                                            </select>-->
                                            <span id="reason"></span>
                                        </div>
                                    </div>

                                    <div>
                                        <table border="1" cellpadding="0" cellspacing="0" width="80%" style="margin-top: 20px;" class="table table-sm">
                                            <thead  style="background-color: #b3d7ff;">
                                            <tr>
                                                <th>序号</th>
                                                <th>产品名称</th>
                                                <th>产品编号</th>
                                                <th>描述</th>
                                                <th>数量</th>
                                                <th>单位</th>
                                                <th>成本单价（元）</th>
                                                <th>小计（元）</th>
                                            </tr>
                                            </thead>
                                            <tbody id="tbodyId">

                                            </tbody>
                                        </table>
                                    </div>

                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-2">
                                            总件数：
                                        </div>
                                        <div class="col-4">
                                            <span id="amountSum"></span>
                                        </div>
                                        <div class="col-2">
                                            总金额：
                                        </div>
                                        <div class="col-4">
                                            <span id="costPriceSum"></span>
                                        </div>
                                    </div>

                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-2">
                                            登记人：
                                        </div>
                                        <div class="col-4">
                                            <span id="register"></span>
                                        </div>
                                        <div class="col-2">
                                            登记时间：
                                        </div>
                                        <div class="col-4">
                                            <span id="registerTime"></span>
                                        </div>
                                    </div>

                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-2">
                                            审核人：
                                        </div>
                                        <div class="col-4">
                                            <span id="checker"></span>
                                        </div>
                                        <div class="col-2">
                                            审核时间：
                                        </div>
                                        <div class="col-4">
                                            <span id="checkTime"></span>
                                        </div>
                                    </div>

                                    <div style="margin-top: 30px;">
                                        <span>备注：</span>
                                        <div  id="remark" style="margin-left: 130px;width: 600px;height: 100px;border: #0b2e13 solid 1px"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </form>
</div>

</body>
</html>